#include <algorithm>
#include <queue>
#include <unordered_map>
#include <vector>
#include <iostream>
using namespace std;

int getDis(vector<int>& A, int n) {
    int ret = 0, _min = A[0];
    for (int i = 1; i < n; i++) {
        _min = min(_min, A[i]);
        ret = max(ret, A[i] - _min);
    }

    return ret;
}

int main()
{
    vector<int> a = { 6,3,2 };
    cout << getDis(a, 3) << endl;
    return 0;
}